﻿using System;

namespace Tallerista.Domain
{
    public interface IRange<T> where T : IComparable
    {
        T Start { get; }
        T End { get; }
        bool Contains(T valueToFind);
    }

    public class Range<T> : IRange<T> where T : IComparable
    {
        private readonly T _start;
        private readonly T _end;

        public Range(T start, T end)
        {
            _start = start;
            _end = end;
        }

        public T End
        {
            get { return _end; }
        }

        public T Start
        {
            get { return _start; }
        }

        public bool Contains(T valueToFind)
        {
            return valueToFind.CompareTo(Start) >= 0 &&
                   valueToFind.CompareTo(End) <= 0;
        }
       
    }
}